package com.sun.controller.admin;

import com.alibaba.fastjson.JSON;
import com.sun.pojo.RoomType;
import com.sun.service.RoomTypeService;
import com.sun.utils.DataGridViewResult;
import com.sun.utils.SystemConstant;
import com.sun.utils.UUIDutiles;
import com.sun.vo.RoomTypeVo;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/admin/roomType")
public class RoomTypeController {

    @Autowired
    private RoomTypeService roomTypeService;

    @RequestMapping("/findAll")
    public DataGridViewResult findAll(RoomTypeVo roomTypeVo) {
        return roomTypeService.findAll(roomTypeVo);
    }

    @RequestMapping("/addRoomType")
    public String addRoomType(RoomType roomType){
        HashMap<String, Object> map = new HashMap<String, Object>();
        if(roomTypeService.addRoomType(roomType)>0){
            map.put(SystemConstant.SUCCESS,true);
            map.put(SystemConstant.MESSAGE,"添加成功!");
        }else{
            map.put(SystemConstant.SUCCESS,false);
            map.put(SystemConstant.MESSAGE,"添加失败!");
        }
        return JSON.toJSONString(map);
    }

    @RequestMapping("/initRoomSelectRoomType")
    public String initRoomSelectRoomType(){
        return JSON.toJSONString(roomTypeService.initRoomSelectRoomType());
    }
}
